﻿<link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/redmond/jquery-ui.css" />
<link rel="stylesheet" type="text/css" href="http://www.ok-soft-gmbh.com/jqGrid/jquery.jqGrid-3.7.2/src/css/ui.jqgrid.css" />
<link rel="stylesheet" type="text/css" href="http://www.ok-soft-gmbh.com/jqGrid/jquery.jqGrid-3.7.2/src/css/jquery.searchFilter.css" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/jquery-ui.js"></script>
<script type="text/javascript" src="http://www.ok-soft-gmbh.com/jqGrid/jquery.jqGrid-3.7.2/src/i18n/grid.locale-en.js"></script>
<script type="text/javascript" src="http://www.ok-soft-gmbh.com/jqGrid/jquery.jqGrid-3.7.2/src/grid.base.js"></script>
<script type="text/javascript" src="http://www.ok-soft-gmbh.com/jqGrid/jquery.jqGrid-3.7.2/src/grid.common.js"></script>
<script type="text/javascript" src="http://www.ok-soft-gmbh.com/jqGrid/jquery.jqGrid-3.7.2/src/grid.formedit.js"></script>
<script type="text/javascript" src="http://www.ok-soft-gmbh.com/jqGrid/jquery.jqGrid-3.7.2/src/grid.inlinedit.js"></script>
<script type="text/javascript" src="http://www.ok-soft-gmbh.com/jqGrid/jquery.jqGrid-3.7.2/src/grid.custom.js"></script>
<script type="text/javascript" src="http://www.ok-soft-gmbh.com/jqGrid/jquery.jqGrid-3.7.2/src/jquery.fmatter.js"></script>
<script type="text/javascript" src="http://www.ok-soft-gmbh.com/jqGrid/jquery.jqGrid-3.7.2/src/jquery.searchFilter.js"></script>
<script type="text/javascript" src="http://www.ok-soft-gmbh.com/jqGrid/jquery.jqGrid-3.7.2/src/grid.jqueryui.js"></script>
<script type="text/javascript">
    $(document).ready(function () {
        var grid = jQuery("#data").jqGrid({
            url: '/AdminCategory/GetListCategories/',
            mtype: 'POST',
            datatype: "json",
            jsonReader: {
                root: "rows",
                page: "page",
                total: "total",
                records: "records",
                repeatitems: false,
                id: "ID"
            },
            colNames: ['ID', 'Name'],
            colModel: [
                { name: 'ID', index: 'ID', width: 35, editable: true, editoptions:{readonly:true}, sorttype: "int" },
                { name: 'Name', index: 'Name', width: 400, editable: true },
            ],
            toolbar: [true, "top"],
            rowNum: 10,
            rowList: [5, 20, 30],
            pager: '#pager',
            sortname: 'ID',
            viewrecords: true,
            sortorder: "desc",
            caption: "Assets",
            editurl: '/AdminCategory/Delete/'
        });
        jQuery("#data").jqGrid('filterToolbar',  { searchOnEnter: true, enableClear: false });
        jQuery("#data").jqGrid('navGrid', '#pager', {  edit: true, add: true, del: true }, {
                mtype: "POST", reloadAfterSubmit: false,
                onclickSubmit: function (rp_ge, postdata) {
                    rp_ge.url = '/AdminCategory/SaveChange?' + 'ID=' + postdata.ID + '&Name=' + postdata.Name;
                }
            },{
                mtype: "POST", reloadAfterSubmit: true,
                onclickSubmit: function (rp_ge, postdata) {
                    rp_ge.url = '/Home/Index';
                    var url = '/AdminCategory/SaveChange?' + 'ID=0' + '&Name=' + postdata.Name;
                    $.ajax({
                        type: "POST",
                        url: url,
                        success: function (data) {
                            $('#abc').html("fjkdjlf");
                        }
                    });
                },
            
            serializeDelData: function (postdata) { return ""; }
        });
    });
</script>
<h2>@ViewBag.Message</h2>>
<br />
<br />
<table id="data" ></table>
<div id="pager"></div>
<br /><br />


